﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Polylines
/// </summary>
public class Polylines : CollectionBase
{
    public Polylines()
    {
    }

    public Polylines Clone()
    {
        Polylines p = new Polylines();
        for (int i = 0; i < this.Count; i++)
        {
            Polyline GPL = new Polyline();
            GPL.ColorCode = this[i].ColorCode;
            GPL.ID = this[i].ID;
            GPL.ArrayPoint = this[i].ArrayPoint.Clone();
            GPL.Width = this[i].Width;
            p.Add(GPL);
        }
        return p;
    }

    public Polyline this[int pIndex]
    {
        get
        {
            return (Polyline)this.List[pIndex];
        }
        set
        {
            this.List[pIndex] = value;
        }
    }

    public Polyline this[string pID]
    {
        get
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].ID == pID)
                {
                    return (Polyline)this.List[i];
                }
            }
            return null;
        }
        set
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i].ID == pID)
                {
                    this.List[i] = value;
                }
            }
        }
    }

    public void Add(Polyline pPolyline)
    {
        this.List.Add(pPolyline);
    }

    public void Remove(int pIndex)
    {
        this.RemoveAt(pIndex);
    }

    public void Remove(string pID)
    {
        for (int i = 0; i < Count; i++)
        {
            if (this[i].ID == pID)
            {
                this.List.RemoveAt(i);
                return;
            }
        }
    }
}